#include <stdio.h>

void shell_sort(double *a, int len)
{
  int i, j, k;
  int gap = len / 2;
  double key;

  while (gap > 0) { 
    for (i = 0; i < gap; i++) 
      for (j = i + gap; j < len; j += gap) {
	key = a[j];
	k = j - gap;
	while (k >= 0 && key < a[k]) {
	  a[k + gap] = a[k];
	  k -= gap;
	}
	a[k + gap] = key;
      }
    gap /= 2;
  }
}
